package fr.istic.linkedcv.server;

import java.util.ArrayList;
import java.util.List;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;

@PersistenceCapable
public class PersonneImpl {

	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key encodedKey;

	@Persistent
	private String login;

	@Persistent
	private String nom;

	@Persistent
	private String prenom;

	@Persistent
	private String password;

	@Persistent
	private CVImpl cvImpl;

	@Persistent
	private String email;

	@Persistent
	private List<Key> groupesSet;

	@Persistent
	private List<Key> listeAmis;
	
	@Persistent
	private List<Key> listMessages; 

	public PersonneImpl() {

	}

	public String getNom() {
		return nom;
	}

	public void setNom(String nom) {
		this.nom = nom;
	}

	public String getPrenom() {
		return prenom;
	}

	public void setPrenom(String prenom) {
		this.prenom = prenom;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public void setLogin(String login) {
		this.login = login;
	}

	public String getLogin() {
		return login;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getPassword() {
		return password;
	}

	public void setCvImpl(CVImpl cvImpl) {
		this.cvImpl = cvImpl;
	}

	public CVImpl getCvImpl() {
		return cvImpl;
	}

	public void setGroupesSet(List<Key> groupesSet) {
		this.groupesSet = groupesSet;
	}

	public List<Key> getGroupesSet() {
		return groupesSet;
	}

	public void addGroupe(Key groupe) {
		if (groupesSet == null) {
			groupesSet = new ArrayList<Key>();
		}
		groupesSet.add(groupe);
	}

	public void removeGroupe(Key groupe){
		groupesSet.remove(groupe);
	}
	public void setEncodedKey(Key encodedKey) {
		this.encodedKey = encodedKey;
	}

	public Key getEncodedKey() {
		return encodedKey;
	}

	public List<Key> getListeAmis() {
		return listeAmis;
	}

	public void setListeAmis(List<Key> listeAmis) {
		this.listeAmis = listeAmis;
	}

	public void addFriend(Key keyFriend) {
		this.listeAmis.add(keyFriend);
	}

	public void removeFriend(Key keyFriend) {
		this.listeAmis.remove(keyFriend);
		
	}

	public List<Key> getListMessages() {
		return listMessages;
	}

	public void setListMessages(List<Key> listMessages) {
		this.listMessages = listMessages;
	}

	public void addMessage(Key key) {
		if(listMessages==null){
			listMessages = new ArrayList<Key>();
		}
		listMessages.add(key);
	}

}
